<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //1.循环计算从100到500的总和
        var sum = 0;
        for (var i = 100; i <= 500; i++) {
            sum += i;
        }
        document.write('100到500的和：' + sum);
        document.write('<br>');

        //2.字符判断是数字还是小写字母还是大写字母还是符号
        var c = window.prompt("输入一个字符:");
        if (c >= 0 && c <= 9) {
            document.write(c + '为数字');
        } else if (c >= 'a' && c <= 'z') {
            document.write(c + '为小写字母');
        } else if (c >= 'A' && c <= 'Z') {
            document.write(c + '为大写字母');
        } else {
            document.write(c + '为符号');
        }
        document.write('<br>');

        //3.密码验证，如果用户名错误，不进行密码验证
        var username = window.prompt("请输入姓名:");
        if (username == 'zhou') {
            var psw = window.prompt("请输入密码:");
            if (psw == '1234') {
                document.write('密码正确，验证成功');
            } else {
                document.write('密码错误');
            }
        } else {
            document.write('用户名错误');
        }
        document.write('<br>');

        //4.水仙花数
        var count = 0;
        for (var j = 100; j <= 999; j++) {
            var g = j % 100;
            var s = parseInt(j / 10) % 10;
            var b = parseInt(j / 100);
            if (j == g * g * g + s * s * s + b * b * b) {
                // document.write(j + '是水仙花数');
                count++;
            }
        }
        document.write('水仙花数的个数为:' + count);
        document.write('<br>');

        //5.计算x的y次方
        var x = window.prompt("请输入x:");
        var y = window.prompt("请输入y:");
        var s = 1;
        if (y < 0) {
            y *= -1
            for (var m = 1; m <= y; m++) {
                s = s * x;
            }
            s = 1 / s;
        } else {
            for (var m = 1; m <= y; m++) {
                s = s * x;
            }
        }

        document.write('x的y次方:' + s); 
    </script>
</head>

<body>

</body>

</html>